package com.ebt.m.proposal_v2.bean;

import android.text.TextUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 主附险编辑计算器返回的数据
 *
 * @author archer.qi
 *         Created on 2017/6/5.
 */
public class InsuranceCalculator {

    public InsuranceOption optCoveragePeriod; /* 保障期间*/
    public InsuranceOption optPaymentPeriod; /* 缴费期间*/
    public InsuranceOption optPremium; /* 保费*/
    public InsuranceOption optCoverage; /* 保额*/

    public InsuranceOption optCUnit; /* 保额单位*/
    public InsuranceOption optPUnit; /* 保费单位*/
    public InsuranceOption optUnitValue; /* 单位值*/

    public InsuranceOption optCalculateMode; /* 保额是否为计算模块，可加减*/
    public InsuranceOption optCalculateValue; /* 保额计算的初始值*/
    public InsuranceOption optMultipleMax; /* 计算最大值*/
    public InsuranceOption optMultipleMin; /* 计算最小值*/
    public InsuranceOption optMultipleStep; /* 单次加减数额*/
    public InsuranceOption optInputDif; /* 计算输入*/

    public List<InsuranceOption> mOptionList;


    public void init(String fieldName, String displayName, String value) {
        /**
         * Premium, Coverage, CoveragePeriod, PaymentPeriod 这四项基本参数，最后上传时要加入到featureData队列中
         * 所以这里不把四个基本参数添加到数组中
         */
        if (!"Premium".equals(fieldName) && !"Coverage".equals(fieldName)
                && !"CoveragePeriod".equals(fieldName) && !"PaymentPeriod".equals(fieldName)) {
            InsuranceOption option = new InsuranceOption();
            option.displayName = displayName;
            option.fieldName = fieldName;
            option.value = value;
            if (mOptionList == null) {
                mOptionList = new ArrayList<>();
            }
            mOptionList.add(option);
        }

        if ("Premium".equals(fieldName)) {
            optPremium = new InsuranceOption();
            optPremium.fieldName = fieldName;
            optPremium.displayName = displayName;
            optPremium.value = value;
            if (TextUtils.isEmpty(optPremium.displayName)) {
                optPremium.displayName = value;
            }
        }
        if ("Coverage".equals(fieldName)) {
            optCoverage = new InsuranceOption();
            optCoverage.fieldName = fieldName;
            optCoverage.displayName = displayName;
            optCoverage.value = value;
            if (TextUtils.isEmpty(optCoverage.displayName)) {
                optCoverage.displayName = value;
            }
        }
        if ("CoveragePeriod".equals(fieldName)) {
            optCoveragePeriod = new InsuranceOption();
            optCoveragePeriod.fieldName = fieldName;
            optCoveragePeriod.displayName = displayName;
            optCoveragePeriod.value = value;
        }
        if ("PaymentPeriod".equals(fieldName)) {
            optPaymentPeriod = new InsuranceOption();
            optPaymentPeriod.fieldName = fieldName;
            optPaymentPeriod.displayName = displayName;
            optPaymentPeriod.value = value;
        }
        if ("CUnit".equals(fieldName)) {
            optCUnit = new InsuranceOption();
            optCUnit.fieldName = fieldName;
            optCUnit.displayName = displayName;
            optCUnit.value = value;
        }
        if ("PUnit".equals(fieldName)) {
            optPUnit = new InsuranceOption();
            optPUnit.fieldName = fieldName;
            optPUnit.displayName = displayName;
            optPUnit.value = value;
        }
        if ("unitValue".equals(fieldName)) {
            optUnitValue = new InsuranceOption();
            optUnitValue.fieldName = fieldName;
            optUnitValue.displayName = displayName;
            optUnitValue.value = value;
        }

        if ("calculateMode".equals(fieldName)) {
            optCalculateMode = new InsuranceOption();
            optCalculateMode.fieldName = fieldName;
            optCalculateMode.displayName = displayName;
            optCalculateMode.value = value;
        }
        if ("CalculateValue".equals(fieldName)) {
            optCalculateValue = new InsuranceOption();
            optCalculateValue.fieldName = fieldName;
            optCalculateValue.displayName = displayName;
            optCalculateValue.value = value;
        }
        if ("multipleMax".equals(fieldName)) {
            optMultipleMax = new InsuranceOption();
            optMultipleMax.fieldName = fieldName;
            optMultipleMax.displayName = displayName;
            optMultipleMax.value = value;
        }
        if ("multipleMin".equals(fieldName)) {
            optMultipleMin = new InsuranceOption();
            optMultipleMin.fieldName = fieldName;
            optMultipleMin.displayName = displayName;
            optMultipleMin.value = value;
        }
        if ("multipleStep".equals(fieldName)) {
            optMultipleStep = new InsuranceOption();
            optMultipleStep.fieldName = fieldName;
            optMultipleStep.displayName = displayName;
            optMultipleStep.value = value;
        }
        if ("inputDif".equals(fieldName)) {
            optInputDif = new InsuranceOption();
            optInputDif.fieldName = fieldName;
            optInputDif.displayName = displayName;
            optInputDif.value = value;
        }

    }


}
